<?php

class Module extends CWebModule
{	
	public $debug = false;
	public $install = false;
	
	// set in init() function
	public $leftNavPath = '';
	
	// set in init() funciton
	public $assetsAlias = '';
	
	// the first time, and caching the result for subsequent use.
	private $_assetsUrl;
	
	public function init()
	{
		parent::init();
		if($this->leftNavPath=='') $this->leftNavPath = Utils::lcfirst($this->id) . '.views.layouts._leftNav';
		if($this->assetsAlias=='') $this->assetsAlias = Utils::lcfirst($this->id) . '.assets';		
	}
	/**
	* Publishes the module assets path.
	* @return string the base URL that contains all published asset files of Rights.
	*/
	public function getAssetsUrl()
	{
		if( $this->_assetsUrl===null )
		{
			$assetsPath = Yii::getPathOfAlias($this->assetsAlias);

			// We need to republish the assets if debug mode is enabled.
			if( $this->debug===true )
				$this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath, false, -1, true);
			else
				$this->_assetsUrl = Yii::app()->getAssetManager()->publish($assetsPath);
		}

		return $this->_assetsUrl;
	}
}